﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;


using Castle.ActiveRecord.Framework;
using TQB.DEMO.Castle.Entities;
using Castle.ActiveRecord;
using Castle.ActiveRecord.Framework.Config;
using System.Reflection;

namespace TQB.DEMO.Castle.WebApp
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            XmlConfigurationSource config = new XmlConfigurationSource(Server.MapPath(@"~/Settings/ActiveRecord.xml"));
            //ActiveRecordStarter.Initialize(config, typeof(Users), typeof(TQBBlog), typeof(TQBPost));
            Assembly asm = Assembly.Load("TQB.DEMO.Castle.Entities");
            ActiveRecordStarter.Initialize(asm, config);

            //IConfigurationSource source = System.Configuration.ConfigurationManager.GetSection("activerecord") as IConfigurationSource;
            //ActiveRecordStar ter.Initialize(source, typeof(Users));

            //　获取数据库连接配置
            //Assembly asm = Assembly.Load("TQB.DEMO.Castle.Entities");
            //ActiveRecordStarter.Initialize(asm, source);

            //　删除数据库架构
            //ActiveRecordStarter.DropSchema();
            //　创建数据库架构　(该方法会删除同名表后再创建，没有必要在此之前调用　DropSchema()　方法。)
            //ActiveRecordStarter.CreateSchema();
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}